package com.lottery.material.utils;

import com.lottery.material.enums.CodeEnum;

/**
 * Description：枚举工具类
 * Created by 朱正磊 on 2019/3/18 0018 下午 2:56
 */
@SuppressWarnings("ALL")
public class EnumUtil {

    /**
     * description：根据枚举code获取枚举
     * user 朱正磊
     * time 2019/3/18 0018 下午 2:56
     * @param code
     * @param enumClass
     * @param <T>
     * @return
     */
    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }

}
